<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="layui/css/layui.css" rel="stylesheet" type="text/css" />
  <link rel="stylesheet" href="./css/style.css">
  <link rel="stylesheet" href="./css/index.css">
  <title>首页</title>
</head>
<body style="background-color:#001737;">
  <!-- 头部的部分 -->
  <div class="source_head"></div>
  <!-- 左半部分 -->
  <div class="source_left">
    <div class="source_type_title">
      总工地数 <span>0722</span><i></i>
    </div>
    <div class="source_type_fine">
      <div class="fine">
        <img src="./images/gongdi1.png" alt="">
        <span>拆迁工地</span>
      </div>
    </div>
    
  </div>
  <div class="source_right">
    <div class="layui-btn-group" style="text-align: right;">
      <button class="layui-btn layui-btn-sm"><i class="layui-icon">时间</i></button>
      <button class="layui-btn layui-btn-sm"><i class="layui-icon">工具</i></button>
    </div>
    <!-- 详情部分 -->
    <div>

    </div>
  </div>
  <div id="mappart" style="width: 100%;height: 100%;"> </div>
</body>
</html>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.10&ak=1XjLLEhZhQNUzd93EjU5nOGQ"></script>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script src="js/echarts.min.js?v=2.1000"></script>
<script src="./js/index.js"></script>
<script src="layui/layui.js?v=1.40"></script>



<script>
  getFetchMap()
  getDrawTown()
  
</script>

<script>
  var x = 3366;
    var y = 1547;
    var preMonth_yyyyMM = getPreMonth_yyyyMM(new Date().pattern("yyyy-MM-dd 00:00:00"));
    var nowMonth_yyyyMM = getNowMonth_yyyyMM(new Date().pattern("yyyy-MM-dd 00:00:00"));
    var tilesUrlsErrorCount = 0; //记录图斑地址错误次数
    var tilesUrlsStatus = true;
    //请求图斑地址如果返回结果不为200 次数超过10次则使用上一个月图斑地址
    var zoom = 12;

    //请求图斑地址如果返回结果不为200 次数超过10次则使用上一个月图斑地址
    var zoom = 12;
    function getTilesUrlReturnStatus () {
      for (var i = 0; i < 9; i++) {
        if (tilesUrlsErrorCount >= 5) {
          tilesUrlsStatus = false;
          break;
        }
        for (var j = 0; j < 6; j++) {
          if (tilesUrlsErrorCount >= 5) {
            tilesUrlsStatus = false;
            break;
          }
          var url = 'http://11.16.127.137:8082/haidian_' + nowMonth_yyyyMM + '/token833769810323949CFCB9C89C7B6733D1/wmts/haidian_' + nowMonth_yyyyMM + '/webmercator/WTMS/haidian_' + nowMonth_yyyyMM + '/webmercator/' + zoom + '/' + x + '/' + y + '.png';
          $.ajax({
            url: url,
            async: false,
            complete: function (xhr, textStatus) {
              // console.log(xhr.status);
              if (xhr.status != 200) {
                tilesUrlsErrorCount++;
              }
            }
          });
          y++;
          if (j == 5) {
            y = 1547;
          }
        }
        x++;
      }
    }
    getTilesUrlReturnStatus();
    
</script>